﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Itfort.Web;

namespace WanPiJie.WebSite
{
	public class PageMustLogin_BabyId : PageMustLogin
	{
		public Baby Baby { get; set; }

		protected override void OnInit(EventArgs e)
		{
			base.OnInit(e);

			var babyId = Request.ToInt32("babyid");
			if (babyId > 0)
			{
				this.Baby = WpjSf.BabyService.GetBaby(babyId);
			}
			else
			{
				var babies = WpjSf.BabyService.GetBabies(LoginUser.Id);
				if (babies.Count > 0)
				{
					babies.OrderByDescending(p => p.Birthday);
					this.Baby = babies[0];
				}
			}
		}
	}
}